package summary;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: 海琳琦
 * @Date: 2022/6/8 15:52
 * https://leetcode.cn/problems/pascals-triangle-ii/
 */
public class Title119 {

    public List<Integer> getRow(int rowIndex) {
        int[][] arr = new int[rowIndex + 1][];
        //初始化
        for (int i = 0; i <= rowIndex; i++) {
            arr[i] = new int[i + 1];
            arr[i][0] = 1;
            arr[i][i] = 1;
        }
        List<Integer> result = new ArrayList<>();
        for (int i = 2; i <= rowIndex; i++) {
            for (int j = 1; j < i; j++) {
                arr[i][j] = arr[i - 1][j - 1] + arr[i - 1][j];
            }
        }
        for (int i = 0; i <= rowIndex; i++) {
            result.add(arr[rowIndex][i]);
        }
        return result;
    }

    public static void main(String[] args) {

    }
}
